<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>class类对象继承</title>
  </head>
  <body>
    <div></div>
    <script>
      class Phone{
        //构造方法
        constructor(name,price){
          this.name = name;
          this.price = price;
        }
        //父类成员属性
        call(){
          console.log("打电话")
        }
      }

      class smartPhone extends Phone{
        //构造函数
        constructor(name,price,color,size){
          super(name,price)//就是父类里面的constructor方法通过这种方法完成调用
          //相当于Phone.call(this,name,price)
          this.color= color;
          this.size = size;
        }
        playGame(){
          console.log('玩游戏');
        }
      }

      //实例对象
      let vivo = new smartPhone('vivo',2999,'黑色','5.5');
      console.log(vivo)
    </script>
  </body>
</html>
